<?php

class Service
{
	
	public static function sendMail($to, $subject, $content, $from = "no-reply@breweryexplorer.us", $name='BreweryExplorer')
	{
		$mail=array(
				'toEmail'=>$to,
				'toName' => $to,
				'fromEmail' => $from,
				'fromName' => $name,
				'subject' => $subject,
				'body' => $content,
		);
		 
		Yii::import("ext.yii-mail.*", true);
		$mailer = new YiiMail();
		$mailer->transportType='smtp';
		$mailer->transportOptions=array(
				'host'=>'box992.bluehost.com',
				'username'=>'no-reply@breweryexplorer.us',
				'password'=>'37yk&hMMKaQBy9dd',
				'port'=>465,
				'encryption'=>'ssl',
		);
		
		$contentType = 'text/html';
		$charset = 'UTF-8';
		 
		$message = new YiiMailMessage();
		$message->setTo( array($mail['toEmail']=>$mail['toName']) );
		$message->setFrom( array($mail['fromEmail']=>$mail['fromName']) );
		$message->setReplyTo( array($mail['fromEmail']=>$mail['fromName']) );
		$message->setSubject($mail['subject']);
		$message->setBody($mail['body'], $contentType, $charset);
		$mailer->send($message);
	}
	
}